
function dialog(dialog_name, hei, wid){

    var src = "/dialogs/" + dialog_name
    
    $.modal('<iframe src="' + src + '" height="' + hei + '" width="' + wid + '" style="border:0">', {
        closeHTML: "",
        containerCss: {
            backgroundColor: "#fff",
            borderColor: "#fff",
            height: hei,
            padding: 0,
            width: wid
        },
        overlayClose: true,
        opacity: 50,
        overlayCss: {
            backgroundColor: "#000000"
        },
        
        
        onOpen: function(dialog){
            dialog.overlay.fadeIn('slow', function(){
                dialog.data.hide();
                dialog.container.fadeIn('slow', function(){
                    dialog.data.slideDown('slow');
                });
            });
        },
        
        onClose: function(dialog){
            dialog.data.fadeOut('slow', function(){
                dialog.container.hide('slow', function(){
                    dialog.overlay.slideUp('slow', function(){
                        $.modal.close();
                    });
                });
            });
        }
        
    });
    
}

function showDialog(ID){
    $('#' + ID).modal({
        overlayClose: true,
        opacity: 50,
        overlayCss: {
            backgroundColor: "#000000"
        },
		
		onOpen: function(dialog){
            dialog.overlay.fadeIn('fast', function(){
                dialog.data.hide();
                dialog.container.fadeIn('slow', function(){
                    dialog.data.slideDown('slow');
                });
            });
        },
        
        onClose: function(dialog){
            dialog.data.fadeOut('fast', function(){
                dialog.container.hide('slow', function(){
                    dialog.overlay.slideUp('slow', function(){
                        $.modal.close();
                    });
                });
            });
        }
		
    });
}

$(function(){
    $('.DateTimeTaskField').datetimepicker();
});

$(function(){
    $('.DeadLineTaskField').datetimepicker();
});

$(function(){
    $('.IntegerTaskField').numeric({
        smallincrement: 1,
        increment: 1
    });
});

$(function(){
    $('.IntegerCatField').numeric({
		smallincrement: 1,
        increment: 1,
		minValue: 1
    });
});

$(function(){
    $('.FloatTaskField').numeric({
        format: '0.00000',
        smallincrement: 0.00001,
        increment: 1
    });
});


function showQuestion(question, ID){
    if (question != 'ao_completed') {
        $('#ao_completed_' + ID).hide('slow');
    }
    if (question != 'ao_share') {
        $('#ao_share_' + ID).hide('slow');
    }
    if (question != 'ao_delete') {
        $('#ao_delete_' + ID).hide('slow');
    }
    $('#' + question + '_' + ID).show('slow');
}

function hideQuestion(ID){
    $('#ao_share_' + ID).hide('slow');
    $('#ao_completed_' + ID).hide('slow');
    $('#ao_delete_' + ID).hide('slow');
    
}


function submitForm(FormID){
    $('#' + FormID).validate({ 
		errorLabelContainer: "#errors_" + FormID,
		wrapper:"li"
	});
	$('#' + FormID).submit();
}


function n(){
}




$(function(){
    $('.draggable').draggable({
        revert: 'invalid',
        revertDuration: 500,
        scroll: true,
        zIndex: 1000,
    });
});

$(function(){
    $('.droppable').droppable({
        accept: '.draggable',
        hoverClass: 'resalted',
        drop: function(event, ui){
            draggID = ui.draggable.attr('id');
            droppID = $(this).attr('id');
            ui.draggable.hide('puff');
            
            if (droppID != 'position_contener') {
                url = '/change_task_parent?task_child_key=' + draggID + '&task_parent_key=' + droppID;
            }
            else {
                url = '/up_task_position?task_child_key=' + draggID;
            }
            
            $(window.location).attr('href', url);
        }
        
    });
});

function toggleTaskContent(ID){
    html = $('#toggleler_' + ID).html();
    if (html == '[+]') {
        $('#toggleler_' + ID).html('[-]');
    }
    else {
        $('#toggleler_' + ID).html('[+]');
    }
    $('#expander_contener_' + ID).toggle('blind');
}

function hideTaskContent(ID){
    $('#' + ID).hide('fast')
}



